﻿<%
Class SesionClass
	'前缀
	Public Mark

	'''构造
	Private Sub Class_Initialize()
		Mark = ""
	End Sub

	'''析构
	Private Sub Class_Terminate()
	End Sub

	'''设置 Session的Timeout属性值
	'p_v:Timeout时间,分钟
    Public Property Let Timeout(Byval p_v)
		If IsNumeric(p_v) Then
			Session.Timeout = p_v
		End If
    End Property

	'''取Session值,默认函数
	'p_k:键名
	Public Default Property Get [Get](Byval p_k)
		If IsObject(Session(Mark & p_k)) Then
			Set [Get] = Session(Mark & p_k)
		Else
			[Get] = Session(Mark & p_k)
		End If
    End Property

	'''设置Session值
	'p_k:键名
	'p_v:键值
	Public Property Let [Get](Byval p_k, Byval p_v)
		If IsObject(p_k) Then
			Set Session(Mark & p_k) = p_v
		Else
			Session(Mark & p_k) = p_v
		End If
    End Property

	'''删除某个Session值
	'p_k:键名
	Public Sub Remove(Byval p_k)
		If IsObject(Session(Mark & p_k)) Then
			Set Session(Mark & p_k) = Nothing
		End If
        Session.Contents.Remove(Mark & p_k)
    End Sub

	'''清空删除所有Session值
	Public Sub RemoveAll()
        Dim t_i
        For Each t_i In Session.Contents
			Session.Contents.Remove(t_i)
        Next
		Session.Abandon()
	End Sub

	'''比较两个Session值是否相等
	'p_o:第一个session对象名
	'p_t:第二个session对象名
	Public Function [Compare](Byval p_o, Byval p_t)
        Dim t_o
        t_o = [Get](p_o)
        Dim t_t
        t_t = [Get](p_t)
        If TypeName(t_o) <> TypeName(t_t) Then
            Compare = False
        Else
            If TypeName(t_o) = "Object" Then
                Compare = (t_o Is t_t)
            Else
                If TypeName(t_o) = "Variant()" Then
                    Compare = (Join(t_o, "^") = Join(t_t, "^"))
                Else
                    Compare = (t_o = t_t)
                End If
            End If
        End If
    End Function
End Class
%>